/**
 * 编辑试吃申请信息
 * @param {} id
 * @param {} title
 * @param {} goodsId
 * @param {} goodsCode
 * @return {}
 */
function updCompanyEatApplyWin(id, title) {
	var updCompanyEatApplyForm = new Ext.form.FormPanel({
		id : 'updCompanyEatApplyForm',
		frame : true,
		buttonAlign : 'center',
		monitorValid : true,
		bodyBorder : false,
		labelWidth : 70,
		reader : new Ext.data.JsonReader({
					success : 'success',
					root : 'data'
				}, [{
							name : "id"
						}, {
							name : "companyName"
						}, {
							name : "companyAddress"
						}, {
							name : "employeeNum"
						}, {
							name : "applyDepartment"
						}, {
							name : "applyUserName"
						}, {
							name : "applyUserPhone"
						}, {
							name : "companyTel"
						}]),
		items : [{
			layout : 'form',
			border : false,
			style : {
				"textAlign" : 'center'
			},
			items : [{
						xtype : 'hidden',
						name : 'id',
						value : id
					}, {
						xtype : 'textfield',
						anchor : '100%',
						labelStyle : "text-align:right;",
						fieldLabel : "<span style='color:#F00'>*</span>公司名称",
						allowBlank : false,
						name : "companyName"
					}, {
						xtype : 'textfield',
						anchor : '100%',
						labelStyle : "text-align:right;",
						fieldLabel : "<span style='color:#F00'>*</span>公司地址",
						allowBlank : false,
						name : "companyAddress"
					}, {
						xtype : 'numberfield',
						anchor : '100%',
						labelStyle : "text-align:right;",
						fieldLabel : "<span style='color:#F00'>*</span>试吃人数",
						allowBlank : false,
						blankText : '试吃人数不能为空',
						allowDecimals : false,// 禁用小数
						allowNegative : false, // 禁用负数
						minValue : 1,
						name : "employeeNum"
					}, {
						xtype : 'textfield',
						anchor : '100%',
						labelStyle : "text-align:right;",
						fieldLabel : "<span style='color:#F00'>*</span>申请部门",
						allowBlank : false,
						name : "applyDepartment"
					}, {
						xtype : 'textfield',
						anchor : '100%',
						labelStyle : "text-align:right;",
						fieldLabel : "<span style='color:#F00'>*</span>申请人",
						allowBlank : false,
						name : "applyUserName"
					}, {
						xtype : 'numberfield',
						anchor : '100%',
						labelStyle : "text-align:right;",
						fieldLabel : "<span style='color:#F00'>*</span>手机号",
						allowBlank : false,
						allowDecimals : false,// 禁用小数
						allowNegative : false, // 禁用负数
						name : "applyUserPhone"
					}, {
						xtype : 'textfield',
						anchor : '100%',
						labelStyle : "text-align:right;",
						fieldLabel : "<span style='color:#F00'>*</span>公司电话",
						allowBlank : false,
						name : "companyTel"
					}]
		}],
		buttons : [{
					text : '确定',
					formBind : true,
					handler : function() {
						updCompanyEatApplyById();
					}
				}, {
					text : "取消",
					handler : function() {
						updCompanyEatApplyWindow.close();
					}
				}]
	});
	var updCompanyEatApplyWindow = new Ext.Window({
				id : 'updCompanyEatApplyWindow',
				closeAction : 'close',
				title : title,
				closable : true,
				plain : true,
				modal : true,
				width : 380,
				height : 290,
				draggable : false, // 不可拖动
				resizable : false, // 不可调整
				buttonAlign : 'center',
				autoDestroy : true,
				layout : 'fit',
				items : [updCompanyEatApplyForm],
				listeners : {
					'show' : function() {
						selectCompanyEatApplyById(id);
					},
					'beforeshow' : function() {
						updCompanyEatApplyWindow.center();
					}
				}
			});
	return updCompanyEatApplyWindow;

};

/**
 * 查询试吃申请对象
 * 
 * @param {}
 *            id
 */
function selectCompanyEatApplyById(id) {
	if (id != null && id != "undefined") {
		Ext.getCmp("updCompanyEatApplyForm").getForm().load({
			url : __ctxPath + "/companyEatApplyManager/selectCompanyEatApplyById",
			params : {
				id : id
			},
			method : "POST",
			waitTitle : "请稍候",
			waitMsg : "正在载入数据...",
			root : "data",
			success : function(form, action) {
				var data = action.result.data;
			},
			failure : function(f, g) {
				Ext.MessageBox.show({
							title : "操作信息",
							msg : "数据加载失败!",
							buttons : Ext.MessageBox.OK,
							icon : Ext.MessageBox.ERROR
						});
			}
		});
	}
}
/**
 * 修改试吃申请信息
 */
function updCompanyEatApplyById() {
	var updCompanyEatApplyForm = Ext.getCmp("updCompanyEatApplyForm");
	console.info(updCompanyEatApplyForm);
	if (updCompanyEatApplyForm.getForm().isValid()) {
		Ext.Msg.confirm("提示框", "确认要保存该试吃申请信息吗?", function(button) {
					if (button == "yes") {
						updCompanyEatApplyForm.getForm().submit({
							url : __ctxPath
									+ '/companyEatApplyManager/updCompanyEatApplyById',
							waitTitle : "请稍候",
							waitMsg : "正在提交表单，请稍候......",
							failure : function(response, options) {
								var jsonData = Ext.util.JSON
										.decode(options.response.responseText);
								Ext.MessageBox.show({
											title : "错误提示",
											msg : jsonData.data,
											buttons : Ext.MessageBox.OK,
											icon : Ext.MessageBox.ERROR
										});
							},
							success : function(response, options) {
								var jsonData = Ext.util.JSON
										.decode(options.response.responseText);
								Ext.MessageBox.show({
											title : "信息提示",
											msg : jsonData.data,
											buttons : Ext.MessageBox.OK,
											icon : Ext.MessageBox.INFO
										});
								Ext.getCmp("updCompanyEatApplyWindow")
										.close();
								var gridPanel = Ext
										.getCmp('companyEatApplyManagerGrid');
								if (typeof(gridPanel) != 'undefined') {
									gridPanel.store.reload();
								}
							}
						});
					}
				});
	}
}